package com.b511.swpu.cementbackend.repository;

import com.b511.swpu.cementbackend.entity.CM_WorkBaseInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface DataAnalysisRepository extends JpaRepository<CM_WorkBaseInfo, String>, JpaSpecificationExecutor<CM_WorkBaseInfo> {

    // 作业公司 列表
    @Query(value = "select distinct cementcompany from BA_WELL",nativeQuery = true)
    List<String> findCompany();

    // 根据作业公司 查询 区域 列表
    @Query(value = "select distinct area from BA_WELL where cementcompany=:cementcompany",nativeQuery = true)
    List<String> findArea(@Param("cementcompany") String cementcompany);

    // 根据 作业公司，区域 查询 区块 列表
    @Query(value = "select distinct block from BA_WELL where cementcompany=:cementcompany and area=:area ",nativeQuery = true)
    List<String> findBlock(@Param("cementcompany") String cementcompany, @Param("area") String area);

    // 根据 作业公司，区域，区块 查询 油田 列表
    @Query(value = "select distinct oilfield from BA_WELL where cementcompany=:cementcompany and area=:area and block=:block",nativeQuery = true)
    List<String> findOilField(@Param("cementcompany") String cementcompany, @Param("area") String area,@Param("block") String block);

}
